<?php
namespace app\apixcx\controller;
use app\admin\model\Relation as RelationModel;

class Relation
{
    protected $RelationModel;

    public function __construct()
    {
        $this->RelationModel = new RelationModel();
    }

    /**
     * edit 编辑用户关系接口
     * uid 当前用户ID
     * cid 名片id
     * type 类型 -1屏蔽关系，0分享1扫码
     */
    public function edit($uid,$cid,$type=2)
    {
        $whereData = [
            'uid' => $uid,
            'cid' => $cid
        ];
        $RelationRes = $this->RelationModel -> where($whereData)->find();
        if($RelationRes){
            $RelationRes->type = $type;
            $res = $RelationRes->save();
            if($res){
                return 1;
            }else{
                return 0;
            }
        }else{
            return 0;
        }
    }

  

}
